var gwextPopupWnd;
var popupWnd;
function wndLoad(path, params, title){
	if(!params) params = 'height=500,width=600,toolbar=no,directories=no,personalbar=no';
	if(!title) title = '';
	gwextPopupWnd = window.open(path, title, params);
	return gwextPopupWnd;
}

function wndClose(callback, scope){
	if(popupWnd && !popupWnd.closed){
		popupWnd.close();
	}
	if(callback) callback.call(scope);
}

function getQueryParameters(){
	var url = window.location.toString();
	//get the parameters
	url.match(/\?(.+)$/);
	var params = RegExp.$1;
	// split up the query string and store in an
	// associative array
	var params = params.split("&");
	var queryStringList = {};
	
	for(var i=0;i<params.length;i++){
		var tmp = params[i].split("=");
	    queryStringList[tmp[0]] = decodeURIComponent(tmp[1]);
	}
	return queryStringList;
}

Popup = function(url, closeCallback, scope, params, title){
	if(!params) params = 'height=500,width=600,toolbar=no,directories=no,personalbar=no';
	if(!title) title = '';
	this.url = url;
	this.closeCallback = closeCallback;
	this.scope = scope;
	this.params = params;
	this.title = title;
	this.window;
	
	this.open = function(){
		if(this.window && !this.window.closed) this.window.close();
		this.window = window.open(this.url, this.title, this.params);
	}
	
	this.close = function(){
		this.closeCallback.call(this.scope);
		if(this.window && !this.window.closed){
			this.window.close();
		}
	}
}

/*
[{"message":"b+ugQmrJlPE",
"blips":{
	"b+ugQmrJlPE":{
		"lastModifiedTime":1304505540620,
		"contributors":["k.y.sergey@googlewave.com"],
		"waveletId":"googlewave.com!conv+root",
		"threadId":"",
		"parentBlipId":null,
		"waveId":"googlewave.com!w+ugQmrJlPD",
		"replyThreadIds":["b+ugQmrJlPF"],
		"creator":"k.y.sergey@googlewave.com",
		"version":98,"content":"\n\n\n \nЕуые\n\nеуые1\nеуые2 \nеуые3\n",
		"blipId":"b+ugQmrJlPE","annotations":[],
		"elements":{},
		"childBlipIds":["b+ugQmrJlPF","b+ugQmrJlPG"]
	},
	"b+ugQmrJlPF":{
		"lastModifiedTime":1304505477121,
		"contributors":["k.y.sergey@googlewave.com"],
		"waveletId":"googlewave.com!conv+root",
		"threadId":"b+ugQmrJlPF",
		"parentBlipId":"b+ugQmrJlPE",
		"waveId":"googlewave.com!w+ugQmrJlPD",
		"replyThreadIds":[],
		"creator":"k.y.sergey@googlewave.com",
		"version":43,
		"content":"\nтест1",
		"blipId":"b+ugQmrJlPF",
		"annotations":[],
		"elements":{},
		"childBlipIds":[]
	},
	"b+ugQmrJlPG":{
		"lastModifiedTime":1304505489927,
		"contributors":["k.y.sergey@googlewave.com"],
		"waveletId":"googlewave.com!conv+root",
		"threadId":"b+ugQmrJlPF",
		"parentBlipId":"b+ugQmrJlPE",
		"waveId":"googlewave.com!w+ugQmrJlPD",
		"replyThreadIds":[],
		"creator":"k.y.sergey@googlewave.com",
		"version":59,
		"content":"\n+++тест2",
		"blipId":"b+ugQmrJlPG",
		"annotations":[],
		"elements":{},
		"childBlipIds":[]
	},
	"b+ugQmrJlPH":{
		"lastModifiedTime":1304506274187,
		"contributors":["k.y.sergey@googlewave.com"],
		"waveletId":"googlewave.com!conv+root",
		"threadId":"",
		"parentBlipId":null,
		"waveId":"googlewave.com!w+ugQmrJlPD",
		"replyThreadIds":[],
		"creator":"k.y.sergey@googlewave.com",
		"version":128,
		"content":"\n+++test3",
		"blipId":"b+ugQmrJlPH",
		"annotations":[],
		"elements":{},
		"childBlipIds":[]
	}
},
"threads":{
	"b+ugQmrJlPF":{
		"id":"b+ugQmrJlPF",
		"blipIds":["b+ugQmrJlPF","b+ugQmrJlPG"],
		"location":22
	}
},
"blipId":"","rawDeltas":null,"rawSnapshot":null,
"waveletData":{"lastModifiedTime":1304508833449,"tags":[],"waveletId":"googlewave.com!conv+root",
"rootThread":{"id":"","blipIds":["b+ugQmrJlPE","b+ugQmrJlPH"],"location":-1},"rootBlipId":"b+ugQmrJlPE","dataDocuments":{},
"waveId":"googlewave.com!w+ugQmrJlPD",
"participants":["k.y.sergey@googlewave.com","volnabloggerbot@appspot.com"],
"version":149,"creator":"k.y.sergey@googlewave.com","title":"","participantRoles":{"k.y.sergey@googlewave.com":"FULL","volnabloggerbot@appspot.com":"FULL"},"creationTime":1304505462790}}
	
]



"threads":{
	"b+ugQmrJlPK":{
		"id":"b+ugQmrJlPK","blipIds":["b+ugQmrJlPK"],"location":9},
	"b+ugQmrJlPF":{
		"id":"b+ugQmrJlPF","blipIds":["b+ugQmrJlPF","b+ugQmrJlPG","b+ugQmrJlPI"],"location":22},
	"b+ugQmrJlPJ":{"id":"b+ugQmrJlPJ","blipIds":["b+ugQmrJlPJ"],"location":-1}},
"blipId":"","rawDeltas":null,"rawSnapshot":null,"waveletData":{"lastModifiedTime":1304510356292,"tags":[],"waveletId":"googlewave.com!conv+root","rootThread":{"id":"","blipIds":["b+ugQmrJlPE","b+ugQmrJlPH"],"location":-1},"rootBlipId":"b+ugQmrJlPE","dataDocuments":{},"waveId":"googlewave.com!w+ugQmrJlPD","participants":["k.y.sergey@googlewave.com","volnabloggerbot@appspot.com"],"version":173,"creator":"k.y.sergey@googlewave.com","title":"","participantRoles":{"k.y.sergey@googlewave.com":"FULL","volnabloggerbot@appspot.com":"FULL"},"creationTime":1304505462790}}}]

"threads":{
	"b+ugQmrJlPK":{
		"id":"b+ugQmrJlPK",
		"blipIds":["b+ugQmrJlPK"],"location":9
	},
	"b+ugQmrJlPF":{
		"id":"b+ugQmrJlPF",
		"blipIds":["b+ugQmrJlPG","b+ugQmrJlPI"],
		"location":22
	},
	"b+ugQmrJlPJ":{
		"id":"b+ugQmrJlPJ","blipIds":["b+ugQmrJlPJ"],"location":-1
	}},"blipId":"","rawDeltas":null,"rawSnapshot":null,"waveletData":{"lastModifiedTime":1304510664973,"tags":[],"waveletId":"googlewave.com!conv+root",
"rootThread":{"id":"","blipIds":["b+ugQmrJlPE","b+ugQmrJlPH"],"location":-1},"rootBlipId":"b+ugQmrJlPE","dataDocuments":{},"waveId":"googlewave.com!w+ugQmrJlPD","participants":["k.y.sergey@googlewave.com","volnabloggerbot@appspot.com"],"version":175,"creator":"k.y.sergey@googlewave.com","title":"","participantRoles":{"k.y.sergey@googlewave.com":"FULL","volnabloggerbot@appspot.com":"FULL"},"creationTime":1304505462790}}}]

"threads":{
	"b+ugQmrJlPK":{
		"id":"b+ugQmrJlPK","blipIds":["b+ugQmrJlPK"],"location":9},
	"b+ugQmrJlPF":{
		"id":"b+ugQmrJlPF",
		"blipIds":["b+ugQmrJlPG","b+ugQmrJlPL","b+ugQmrJlPI"],"location":22},
		"b+ugQmrJlPJ":{"id":"b+ugQmrJlPJ","blipIds":["b+ugQmrJlPJ"],"location":-1}
	},"blipId":"","rawDeltas":null,"rawSnapshot":null,"waveletData":{"lastModifiedTime":1304513802183,"tags":[],"waveletId":"googlewave.com!conv+root","rootThread":{"id":"","blipIds":["b+ugQmrJlPE","b+ugQmrJlPH"],"location":-1},"rootBlipId":"b+ugQmrJlPE","dataDocuments":{},"waveId":"googlewave.com!w+ugQmrJlPD","participants":["k.y.sergey@googlewave.com","volnabloggerbot@appspot.com","screencopyer@appspot.com"],"version":185,"creator":"k.y.sergey@googlewave.com","title":"","participantRoles":


"threads":{
	"b+ugQmrJlPK":{"id":"b+ugQmrJlPK","blipIds":["b+ugQmrJlPK"],"location":9},
	"b+ugQmrJlPM":{"id":"b+ugQmrJlPM","blipIds":["b+ugQmrJlPM"],"location":-1},
	"b+ugQmrJlPF":{"id":"b+ugQmrJlPF","blipIds":["b+ugQmrJlPG","b+ugQmrJlPL","b+ugQmrJlPI"],"location":22},
	"b+ugQmrJlPJ":{"id":"b+ugQmrJlPJ","blipIds":["b+ugQmrJlPJ"],"location":-1}},"blipId":"","rawDeltas":null,"rawSnapshot":null,"waveletData":{"lastModifiedTime":1304513930072,"tags":[],"waveletId":"googlewave.com!conv+root","rootThread":{"id":"","blipIds":["b+ugQmrJlPE","b+ugQmrJlPH"],"location":-1},"rootBlipId":"b+ugQmrJlPE","dataDocuments":{},"waveId":"googlewave.com!w+ugQmrJlPD","participants":["k.y.sergey@googlewave.com","volnabloggerbot@appspot.com","screencopyer@appspot.com"],"version":193,"creator":"k.y.sergey@googlewave.com","title":"","participantRoles":
}
	
	}*/